<template>
	<view class="container">
		<view class="notifiList">
			<view class="listLi" v-for="(item,index) in listData" :data-id="item.id" @click="goDetail">
				<view class="title">标题：{{item.title}}</view>
				<view class="time">时间：{{silceTime(item.createTime)}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listData:[]
			}
		},
		onLoad() {
			this.$http.get("/notice/v1/list.do",{
				params:''
			}).then(res=>{
				console.log(res);
				this.listData = res.data.rows;
				this.listData = this.listData.map((item)=>{
					return{
						id:item.id,
						createTime:item.createTime,
						title:item.title
					}
				})
			}).catch(e=>{
				console.log("请求错误",e)
			})
		},
		methods: {
			silceTime(timeText){
				return timeText.substring(0,10)
			},
			goDetail(e){
				let id = e.currentTarget.dataset.id;
				console.log(id);
				uni.navigateTo({
					url:"/pages/notification/notifDetail?id="+id
				})
			}
		}
	}
</script>

<style>
	@import "uni.css";
	page{
		font-family: "my-font";
	}
	.container{
		width: 100%;
	}
	.notifiList{
		width: 100%;
		border-top: solid #F2F2F2 1px;
		padding: 0 20px;
	}
	.listLi{
		width: 100%;
		/* height: 80px; */
		padding: 10px 0px;
		box-sizing: border-box;
		/* display: flex;
		align-items: center; */
		border-bottom: solid #F2F2F2 1px;
	}
	.title{
		font-size: 18px;
		color: #666;
	}
	.time{
		font-size: 14px;
		color: #999;
		margin-top: 10px;
	}
</style>
